/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-03-08 11:16:14
 * @LastEditTime : 2023-06-28 14:29:43
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\TypeRelationMap.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { CenterTypes, DataSynchronization } from '../Common/Conversion'

export const TypeRelationMap = async ({ url, OptionsEvent }) => {
    const tableName = await CenterTypes()
    const centerUuid = await DataSynchronization()

    let data = {
        type: '系统配置',
        pageSize: 10000,
        params: { pageIndex: 1, OrderField: 'tableName@asc,centerTypeName@asc' },
        get: API_LIST()['getTypeRelationMapListTypesRelations'],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        // exportExcel: true,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增映射关系" />,
        ],
        columns: [
            commonTableList.uuid,
            {
                ...commonTableList.tableName,
                title: '表名',
                valueType: 'select',
                valueEnum: tableName,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'tableName',
                title: '表名',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'centerTypeName',
                title: '中心名称',
                valueType: 'input',
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'centerTypeUuid',
                title: '中心ID',
                valueType: 'input',
                width: 300,
                ellipsis: true,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'typeName',
                title: '本地名称',
                valueType: 'input',
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'typeUuid',
                title: '本地ID',
                valueType: 'input',
                width: 300,
                ellipsis: true,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'centerName',
                title: '上传位置',
                valueType: 'input',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 100,
            },
            {
                dataIndex: 'centerUuid',
                title: '上传位置',
                valueType: 'select',
                valueEnum: centerUuid,
                hideInSearch: true,
                hideInTable: true,
                width: 100,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 160,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" url={url} data={record} />,

                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return data
}
